package com.lz.test;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.stubbing.OngoingStubbing;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import java.util.HashMap;
import java.util.Map;

/**
 * @description
 *
 * @date 2021-11-24 11:15
 *
 * @author Lizhong
 */
@RunWith(PowerMockRunner.class)
@PrepareForTest(IDNumberUtils.class)
public class PowerMokit {

    @Test
    public void  t1(){
        PowerMockito.mockStatic(IDNumberUtils.class);
        Map<String, String> t = new HashMap<>();
        t.put("1","a");
        OngoingStubbing<Map<String, String>> opt = PowerMockito.when(IDNumberUtils.getBirAgeSex(ArgumentMatchers.anyString())).thenReturn(t);
        Map<String, String> map = IDNumberUtils.getBirAgeSex("d");
        String s = map.get("1");
        Assert.assertEquals("a",s);
    }
}
